// page/mall/mall.js
Page({
    data: {
        isHide: 0,
        tabs: ["兑换课时", "兑换商品"],
        activeIndex: 0,
        sliderOffset: 0,
        courseItem: [],
        integralItem: []
    },
    onLoad: function (options) {
        var app = getApp()
        var that = this;
        var uid = wx.getStorageSync('uid');
        that.setData({
            options: options
        })
        wx.request({
          url: app.globalData.host + '&g=App&m=Index&a=feedback',
          data: {
            uid: uid,
          },
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {
            console.log(res.data)
            var scene = res.data.scene
            that.setData({
              scene: res.data.scene
            })
          }
        })
        this.setData({
            isHide: 1,
        })
    },
    onShow: function(){
        var app = getApp()
        var that = this;
        wx.request({
            url: app.globalData.host + '&g=App&m=Item&a=index',
            data: { },
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
              // console.log(res.data)
                that.setData({
                    listItem: res.data.list,
                    page:res.data.page
                })
                //   console.log(that.data.coachItem)
            }
            

        }),
            wx.request({
                url: app.globalData.host + '&g=App&m=Goods&a=index',
                data: {},
                header: {
                    'content-type': 'application/json'
                },
                success: function (res) {
                    // console.log(res.data)
                    that.setData({
                        lisItem: res.data.list,
                        page: res.data.page
                    })
                    //   console.log(that.data.coachItem)
                }
            })
        
    },
     tabClick: function (e) {
        this.setData({
            sliderOffset: e.currentTarget.offsetLeft,
            activeIndex: e.currentTarget.id
        });
    },
     // 分享
     onShareAppMessage: function (res) {
       var uid = wx.getStorageSync('uid');
       var that = this;
       var app = getApp()
       var scene = that.data.scene
       console.log(that.data.scene)
       console.log("1")
       if (res.from === 'button') {
         // 来自页面内转发按钮
         return {
           title: '兴祥安驾校',
           path: '/page/mall/mall?scene=scene',
           success: function (res) {
             // 转发成功
             wx.request({
               url: app.globalData.host + '&g=App&m=Index&a=feedback',
               data: {
                 scene: scene
               },
               header: {
                 'content-type': 'application/json'
               },
             })
           },
           fail: function (res) {
             // 转发失败
           }
         }
         console.log(res.target)
       }
       return {
         title: '兴祥安驾校',
         path: 'page//mall/mall?scene=scene',
         success: function (res) {
           // 转发成功
           wx.request({
             url: app.globalData.host + '&g=App&m=Index&a=feedback',
             data: {
               scene: scene
             },
             header: {
               'content-type': 'application/json'
             },
           })
         },
         fail: function (res) {
           // 转发失败
         }
       }
     }
})